<?php if(!defined('APP_ROOT')){exit('error!');}?>
<div id="sidebox">
    <div class="wrapper">
        <ul id="sidenav">
            <li class="item">
                <a href="<?php echo APP_URL;?>manage/index"><i class="fa fa-home"></i>管理首页</a>
            </li>
            <li class="item">
                <a href="<?php echo APP_URL;?>record/index"><i class="fa fa-list"></i>我的录入</a>
                <i class="switch fa fa-caret-down"></i>
                <ul class="sub-nav">
                    <li class="sub-item"><a href="<?php echo APP_URL;?>record/edit"><i class="fa fa-pencil-square"></i>新建录入</a></li>
                </ul>
            </li>
            <li class="item">
                <a href="<?php echo APP_URL;?>report/index"><i class="fa fa-line-chart"></i>查看报表</a>
            </li>
            <li class="item"><a href="<?php echo APP_URL;?>shop/index"><i class="fa fa-building"></i>店铺管理</a></li>
            <li class="item"><a href="<?php echo APP_URL;?>ditches/index"><i class="fa fa-share-alt"></i>渠道管理</a></li>
            <li class="item"><a href="<?php echo APP_URL;?>user/index"><i class="fa fa-group"></i>用户管理</a></li>
            <li class="item"><a href="<?php echo APP_URL;?>options/index"><i class="fa fa-cog"></i>系统设置</a></li>
        </ul>
    </div>
</div>
<script type="text/javascript">
$(function(){
    
    $("#sidenav li.item:has(ul)").each(function(index){
        var item = $(this);

            item.append('<i class="switch fa fa-caret-down"></i>');

            var outTimer = 0;
            var hoverTimer = 0;
            item.hover(function(){
                clearTimeout(outTimer);
                hoverTimer = setTimeout(function(){
                    item.find("ul.sub-nav").fadeIn(200);
                    item.find("i.switch").css({"transform":"rotate(-90deg)"});
                },100);
            },function(){
                clearTimeout(hoverTimer);
                outTimer = setTimeout(function(){
                    item.find("ul.sub-nav").hide();
                    item.find("i.switch").css({"transform":"rotate(0)"});
                },200);
            });
    });
})
</script>